<template>
  <div class="strategy-info">
    <el-form :model="form" ref="formRef" label-width="120px">
      <el-form-item label="平台名" prop="name" required>
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="备注" prop="remarks">
        <el-input v-model="form.remarks"></el-input>
      </el-form-item>
    </el-form>

    <div class="btn-area">
      <el-button @click="emit('close')">取消</el-button>
      <el-button type="primary" @click="handleConfirm">确认</el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import type { PlatformItem } from './model'
import type { AimType } from '@/hooks/useTable'

const props = defineProps<{
  info: PlatformItem
  aim: AimType
}>()

const form = ref<PlatformItem>({
  ...props.info
})

const emit = defineEmits(['close', 'confirm'])

const formRef = ref()
const handleConfirm = () => {
  formRef.value.validate((valid: boolean) => {
    if (valid) {
      emit('confirm', form.value)
    }
  })
}
</script>

<style lang="scss" scoped>
.strategy-info {
  .btn-area {
    text-align: end;
  }
}
</style>
